Tag Link | [Net->Wait] | Category | Networking |
---|---|---|---|
Type | Member | Source Available | Yes |
Support | Preferred | Version | 7.0 |
Change | Unchanged | Data Source | Any |
Output Type | Integer | Security | None |
Implementation | LCAPI | Sets | Lasso 8.5, Lasso 8.0, Lasso 7.0 |
The [Net->Wait] tag makes a [Net] object wait until data is ready for reading or writing. The tag takes two parameters. The first is a timeout period in seconds. The second specifies what condition the [Net->Wait] tag should wait for. The return value of the tag is either [Net_WaitRead], [Net_WaitWrite], or [Net_WaitTimeOut].
[Net_WaitRead] instructs [Net->Wait] to wait until there is data available for reading. [Net_WaitRead] will be returned as the value of the tag or [Net_WaitTimeOut] if the timeout period is reached before any data was made available for reading.
[Net_WaitWrite] instructs [Net->Wait] to wait until the connection can accept data for a write opertion. [Net_WaitWrite] will be returned as the value of the tag or [Net_WaitTimeOut] if the timeout period is reached before the connection became available for writing.
With no second parameter [Net->Wait] returns either [Net_WaitRead] or [Net_WaitWrite] depending on which state becomes available first. [Net_WaitTimeOut] is returned if the connection does not have data available for reading and is not avalable for writing before the timeout period is reached.
<?LassoScript
Variable: 'Connection' = (Net);
$Net->(Connect: 'www.example.com', '80');
If: ($Net->(Wait: 60, Net_WaitWrite) == Net_WaitWrite);
Output: 'Connection is ready for writing.';
/If;
?>
Required Parameters | |
---|---|
Time Out Period | The time in seconds that the tag should wait before timing out. |
Optional Parameters | |
Wait Type | The optional condition that the tag should wait for. Either [Net_WaitRead] or [Net_WaitWrite]. |
To connect to a remote server using non-blocking TCP:
Use the [Net] type and its member tags to establish a TCP connection. The following example opens a non
[Variable: 'myConnection' = (Net)]
[$myConnection->(SetBlocking: False)]
[Var: 'Result' = $myConnection->(Connect: 'www.example.com', 80)]
[Fail_If: $Result != Net_ConnectOK, (-1), 'TCP Error']
[Var: 'Result' = $myConnection->(Wait: 60, Net_WaitWrite)]
[Fail_If: $Result == Net_WaitTimeOut, (-1), 'TCP Timeout']
[Variable: 'Result' = $myConnection->(Write: 'GET / HTTP/1.0\r\n\r\n')]
[Var: 'Result' = $myConnection->(Wait: 60, Net_WaitRead)]
[Fail_If: $Result == Net_WaitTimeOut, (-1), 'TCP Timeout']
[Variable: 'Output' = $myConnection->(Read: 32768)]
[$myConnection->(Close)]
[Output: $Output]
<html><head><title>HTML Document</title></head>>body> ...